<template>
  <ContentWrap>
    <div class="w-100% text-right mb-20px">
      <el-button type="primary" @click="openFrom('create')"
        ><Icon icon="ep:plus" class="mr-5px" />新增</el-button
      >
    </div>
    <el-table :data="list" style="width: 100%">
      <el-table-column prop="title" label="标题"> </el-table-column>
      <el-table-column prop="keys" label="关键词" show-overflow-tooltip> </el-table-column>
      <el-table-column prop="knowledgeType" label="问题类型">
        <template #default="scope">
          <el-tag type="primary">{{
            scope.row.knowledgeType == 1 ? '一般业务' : '业务问题'
          }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="id" label="编辑" align="center">
        <template #default="scope">
          <el-button type="primary" link @click="openFrom('update', scope.row.id)">编辑</el-button>
          <el-button type="danger" link @click="del(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>
  <SuperForm ref="superRef" @success="getList" />
</template>

<script setup>
import * as defaultIvrKnowApi from '@/api/call/manage'
import SuperForm from './superFrom.vue'
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10
})
const superRef = ref(false)
const list = ref([])
const total = ref(0)
const getList = async () => {
  const data = await defaultIvrKnowApi.getIvrDefaultknow(queryParams)
  list.value = data.list
  total.value = data.total
}
const openFrom = (type, id) => {
  superRef.value.open(type, id)
}
const del = async (id) => {
  await ElMessageBox.confirm(`确定删除此条数据吗？`)
  await defaultIvrKnowApi.deleteIvrDefaultknow(id)
  ElMessage.success('操作成功')
  getList()
}
onMounted(() => {
  getList()
})
</script>

<style lang="scss" scoped></style>
